home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 71.zip / BS1 part 71 / AmosPro2.0_d5.adf / Extensions / |io_Ports.s < prev    next >
Text File  |  1992-09-28  |  23KB  |  1,030 lines

  1.  
  2. ;---------------------------------------------------------------------
  3. ;    **   **   **  ***   ***   ****     **    ***  **  ****
  4. ;   ****  *** *** ** ** **     ** **   ****  **    ** **  **
  5. ;  **  ** ** * ** ** **  ***   *****  **  **  ***  ** **
  6. ;  ****** **   ** ** **    **  **  ** ******    ** ** **
  7. ;  **  ** **   ** ** ** *  **  **  ** **  ** *  ** ** **  **
  8. ;  **  ** **   **  ***   ***   *****  **  **  ***  **  ****
  9. ;---------------------------------------------------------------------
  10. ; Serial / Parallel / Printer extension source code
  11. ; By François Lionet
  12. ; AMOS, AMOSPro, AMOS Compiler (c) Europress Software 1990-1992
  13. ; To be used with AMOSPro V1.0 and over
  14. ;--------------------------------------------------------------------- 
  15. ; This file is public domain
  16. ;---------------------------------------------------------------------
  17. ;
  18. ; Please refer to the _Music.s file for more informations...
  19. ;
  20. ;---------------------------------------------------------------------
  21.  
  22. Version        MACRO
  23.         dc.b    "1.0"
  24.         ENDM
  25.  
  26.  
  27. * AMIGA's includes
  28.         INCDIR        ":Includes/I/"
  29.         INCLUDE        "Exec/Types.I"
  30.         INCLUDE        "Exec/Exec.I"
  31.         INCLUDE     "Devices/Serial.I"
  32.         INCLUDE        "Devices/PrtBase.I"
  33.         INCLUDE        "Devices/Printer.I"
  34.         INCLUDE        "Devices/PrtGfx.I"
  35.         INCLUDE        "Devices/Parallel.I"
  36.  
  37. *************** AMOS includes
  38. ExtNb        equ    6-1
  39.  
  40.         Include    "|AMOS_Includes.s"
  41.  
  42. Dlea        MACRO
  43.         move.l    ExtAdr+ExtNb*16(a5),\2
  44.         add.w    #\1-DT,\2
  45.         ENDM
  46. Dload        MACRO
  47.         move.l    ExtAdr+ExtNb*16(a5),\1
  48.         ENDM
  49.  
  50. * Number of serial channels allowed
  51. NSerial        equ    4
  52.  
  53. ******************************************************************
  54. *    Header
  55. Start    dc.l    C_Tk-C_Off
  56.     dc.l    C_Lib-C_Tk
  57.     dc.l    C_Title-C_Lib
  58.     dc.l    C_End-C_Title
  59.     dc.w    0    
  60.  
  61. ******************************************************************
  62. *    Offsets to library
  63. C_Off   dc.w (L1-L0)/2,(L2-L1)/2,(L3-L2)/2,(L4-L3)/2
  64.         dc.w (L5-L4)/2,(L6-L5)/2,(L7-L6)/2,(L8-L7)/2
  65.         dc.w (L9-L8)/2,(L10-L9)/2,(L11-L10)/2,(L12-L11)/2
  66.         dc.w (L13-L12)/2,(L14-L13)/2,(L15-L14)/2,(L16-L15)/2
  67.         dc.w (L17-L16)/2,(L18-L17)/2,(L19-L18)/2,(L20-L19)/2
  68.         dc.w (L21-L20)/2,(L22-L21)/2,(L23-L22)/2,(L24-L23)/2
  69.         dc.w (L25-L24)/2,(L26-L25)/2,(L27-L26)/2,(L28-L27)/2
  70.         dc.w (L29-L28)/2,(L30-L29)/2,(L31-L30)/2,(L32-L31)/2
  71.         dc.w (L33-L32)/2,(L34-L33)/2,(L35-L34)/2,(L36-L35)/2
  72.         dc.w (L37-L36)/2,(L38-L37)/2,(L39-L38)/2,(L40-L39)/2
  73.         dc.w (L41-L40)/2,(L42-L41)/2,(L43-L42)/2,(L44-L43)/2
  74.         dc.w (L45-L44)/2,(L46-L45)/2,(L47-L46)/2,(L48-L47)/2
  75.         dc.w (L49-L48)/2,(L50-L49)/2,(L51-L50)/2,(L52-L51)/2
  76.         dc.w (L53-L52)/2,(L54-L53)/2,(L55-L54)/2,(L56-L55)/2
  77.         dc.w (L57-L56)/2,(L58-L57)/2,(L59-L58)/2,(L60-L59)/2
  78.         dc.w (L61-L60)/2,(L62-L61)/2,(L63-L62)/2,(L64-L63)/2
  79.         dc.w (L65-L64)/2,(L66-L65)/2,(L67-L66)/2,(L68-L67)/2
  80.         dc.w (L69-L68)/2,(L70-L69)/2,(L71-L70)/2,(L72-L71)/2
  81.  
  82. ******************************************************************
  83. *    TOKEN TABLE
  84. C_Tk    dc.w     1,0
  85.     dc.b     $80,-1
  86.     dc.w    L_SerOp2,-1
  87.     dc.b    "!serial ope","n"+$80,"I0,0",-2
  88.     dc.w    L_SerOp5,-1
  89.     dc.b    $80,"I0,0,0,0,0",-1
  90.     dc.w    L_SerClo0,-1
  91.     dc.b    "!serial clos","e"+$80,"I",-2
  92.     dc.w    L_SerClo1,-1
  93.     dc.b    $80,"I0",-1
  94.     dc.w    L_SerSp,-1
  95.     dc.b    "serial spee","d"+$80,"I0,0",-1
  96.     dc.w    -1,L_SerChk
  97.     dc.b    "serial chec","k"+$80,"00",-1
  98.     dc.w     L_SerSend,-1
  99.     dc.b    "serial sen","d"+$80,"I0,2",-1
  100.     dc.w     L_SerSp,-1
  101.     dc.b    "serial spee","d"+$80,"I0,0",-1
  102.     dc.w     L_SerBit,-1
  103.     dc.b    "serial bit","s"+$80,"I0,0,0",-1
  104.     dc.w     L_SerX,-1
  105.     dc.b    "serial ","x"+$80,"I0,0",-1
  106.     dc.w     L_SerBuf,-1
  107.     dc.b    "serial bu","f"+$80,"I0,0",-1
  108.     dc.w     L_SerPar,-1
  109.     dc.b    "serial parit","y"+$80,"I0,0",-1
  110.     dc.w    -1,L_SerGet
  111.     dc.b    "serial ge","t"+$80,"00",-1
  112.     dc.w    -1,L_SerInp
  113.     dc.b    "serial input","$"+$80,"20",-1
  114.     dc.w    L_SerFast,-1
  115.     dc.b    "serial fas","t"+$80,"I0",-1
  116.     dc.w    L_SerSlow,-1
  117.     dc.b    "serial slo","w"+$80,"I0",-1
  118.     dc.w    -1,L_SerE
  119.     dc.b    "serial erro","r"+$80,"00",-1
  120.     dc.w    L_SerOut,-1
  121.     dc.b    "serial ou","t"+$80,"I0,0,0",-1
  122.     dc.w    -1,L_SerStatus
  123.     dc.b    "serial statu","s"+$80,"00",-1
  124.     dc.w    -1,L_SerBase
  125.     dc.b    "serial bas","e"+$80,"00",-1
  126.     dc.w    L_SerAbort,-1
  127.     dc.b    "serial abor","t"+$80,"I0",-1
  128.     
  129. ; Printer commands
  130. ; ~~~~~~~~~~~~~~~~
  131.     dc.w       L_PrtOpen,-1
  132.     dc.b    "printer ope","n"+$80,"I",-1
  133.     dc.w    L_PrtClose,-1
  134.     dc.b    "printer clos","e"+$80,"I",-1
  135.     dc.w    L_PrtSend,-1
  136.     dc.b    "printer sen","d"+$80,"I2",-1
  137.     dc.w    L_PrtRaw,-1
  138.     dc.b    "printer ou","t"+$80,"I0,0",-1
  139.     dc.w    L_PrtDump1,-1
  140.     dc.b    "!printer dum","p"+$80,"I0",-2    
  141.     dc.w    L_PrtDump2,-1
  142.     dc.b    $80,"I0,0t0,0",-2 
  143.     dc.w    L_PrtDump3,-1
  144.     dc.b    $80,"I0,0t0,0,0,0,0",-1    
  145.     dc.w    L_PrtAbort,-1
  146.     dc.b    "printer abor","t"+$80,"I",-1
  147.     dc.w    -1,L_PrtCheck
  148.     dc.b     "printer chec","k"+$80,"0",-1
  149.     dc.w    -1,L_PrtOnLine
  150.     dc.b    "printer onlin","e"+$80,"0",-1
  151.     dc.w    -1,L_PrtBase
  152.     dc.b    "printer bas","e"+$80,"0",-1
  153.     dc.w    -1,L_PrtError
  154.     dc.b    "printer erro","r"+$80,"0",-1
  155. ; Parallel commands
  156. ; ~~~~~~~~~~~~~~~~~
  157.     dc.w       L_ParOpen,-1
  158.     dc.b    "parallel ope","n"+$80,"I",-1
  159.     dc.w    L_ParClose,-1
  160.     dc.b    "parallel clos","e"+$80,"I",-1
  161.     dc.w    L_ParSend,-1
  162.     dc.b    "parallel sen","d"+$80,"I2",-1
  163.     dc.w    L_ParRaw,-1
  164.     dc.b    "parallel ou","t"+$80,"I0,0",-1
  165.     dc.w    L_ParAbort,-1
  166.     dc.b    "parallel abor","t"+$80,"I",-1
  167.     dc.w    -1,L_ParCheck
  168.     dc.b     "parallel chec","k"+$80,"0",-1
  169.     dc.w    -1,L_ParStatus
  170.     dc.b    "parallel statu","s"+$80,"0",-1
  171.     dc.w    -1,L_ParBase
  172.     dc.b    "parallel bas","e"+$80,"0",-1
  173.     dc.w    -1,L_ParError
  174.     dc.b    "parallel erro","r"+$80,"0",-1
  175.     dc.w    -1,L_ParInput1
  176.     dc.b    "!parallel input","$"+$80,"20",-2
  177.     dc.w    -1,L_ParInput2
  178.     dc.b    $80,"20,0",-2
  179.  
  180.     dc.w    0
  181. C_Lib
  182.  
  183. ******************************************************************
  184. *        COLD START
  185. L0    movem.l    a3-a6,-(sp)
  186.     lea    DT(pc),a3
  187.     move.l    a3,ExtAdr+ExtNb*16(a5)
  188.     lea    SerDef(pc),a0
  189.     move.l    a0,ExtAdr+ExtNb*16+4(a5)
  190.     lea    SerEnd(pc),a0
  191.     move.l    a0,ExtAdr+ExtNb*16+8(a5)
  192.     movem.l    (sp)+,a3-a6
  193.     moveq    #ExtNb,d0        * NO ERRORS
  194.     rts
  195.  
  196. ******* SCREEN RESET
  197. SerDef    
  198. ******* QUIT
  199. SerEnd    Rbsr    L_SCloseA
  200.     Dlea    PrinterIO,a2
  201.     Rjsr    L_Dev.Close
  202.     Dlea    ParallelIO,a2
  203.     Rjsr    L_Dev.Close
  204.     rts
  205.  
  206. *************** Data zone
  207. DT
  208. SerialIO    ds.l    3*NSerial    Serial IO Port
  209. PrinterIO    ds.l    3        Printer IO Port
  210. ParallelIO    ds.l    3        Parallel IO Port
  211. BufIn        dc.l    0
  212. Prt_Query    dc.l    0        Espace pour informations
  213.  
  214. ; Screen Dump
  215. ; ~~~~~~~~~~~
  216. width:        dc.w    0
  217. height:        dc.w    0
  218. viewModes    dc.w    0
  219. depth:        dc.w    0
  220. screen        dc.l    0
  221. vPort        dc.l    0
  222. rPort        dc.l    0
  223. colourmap    dc.l    0
  224. oldCtable    dc.l    0
  225. special        dc.w    $84
  226. srcX        dc.w    0
  227. srcY        dc.w    0
  228. pwidth        dc.w    0
  229. pheight        dc.w    0
  230. temp1        dc.w    0
  231. temp2        dc.w    0
  232. destCols    dc.l    0
  233. destRows    dc.l    0
  234. ScreenBase:    dc.l     0
  235.  
  236. ; Nom des devices
  237. ; ~~~~~~~~~~~~~~~
  238. SerName        dc.b    "serial.device",0
  239. PrtName        dc.b    "printer.device",0
  240. ParName        dc.b    "parallel.device",0
  241.         even
  242.  
  243. L1
  244. L2
  245.  
  246. ***********************************************************
  247. *    OPEN SERIAL DEVICE
  248.  
  249. ******* Seropen logicnumber,physicnumber[,shared,xdisabled,7wires]    
  250. L_SerOp2    equ    3
  251. L3    clr.l    -(a3)
  252.     clr.l    -(a3)
  253.     clr.l    -(a3)
  254.     Rbra    L_SerOp5
  255. L_SerOp5    equ    4
  256. L4    move.l    16(a3),d0
  257.     Rbsr    L_GetSerial
  258. ; Opening parameters
  259.     move.w    #IO_SERFLAGS,d5
  260.     swap    d5
  261.     clr.w    d5
  262.     tst.l    (a3)+
  263.     beq.s    SerOpA
  264.     bset    #SERB_7WIRE,d5
  265. SerOpA    bset    #SERB_XDISABLED,d5
  266.     tst.l    (a3)+
  267.     beq.s    SerOpB
  268.     bclr    #SERB_XDISABLED,d5
  269. SerOpB  tst.l    (a3)+
  270.     beq.s    SerOpC
  271.     bset    #SERB_SHARED,d5
  272. SerOpC    Dlea    SerName,a0
  273.     moveq    #IOEXTSER_SIZE,d0
  274.     move.l    (a3),d1
  275.     moveq    #0,d2
  276.     move.w    #145,d3
  277.     moveq    #16,d4
  278.     Rjsr    L_Dev.Open
  279.     move.l    (a3)+,d0
  280.     addq.l    #4,a3
  281.     beq.s    .PaSet
  282. * If NOT user-serial (#0),
  283. * default settings for French MINITEL: 1200/7/1 Stop/EVEN parity
  284.     move.l    (a2),a1
  285.     move.l    #1200,IO_BAUD(a1)
  286.     move.b    #7,IO_READLEN(a1)
  287.     move.b    #7,IO_WRITELEN(a1)
  288.     move.b    #1,IO_STOPBITS(a1)
  289.     bset    #SERB_XDISABLED,IO_SERFLAGS(a1)
  290.     bset    #SERB_PARTY_ON,IO_SERFLAGS(a1)
  291.     bclr    #SERB_PARTY_ODD,IO_SERFLAGS(a1)
  292.     bclr    #SEXTB_MSPON,IO_EXTFLAGS+3(a1)
  293.     bclr    #SEXTB_MARK,IO_EXTFLAGS+3(a1)
  294. * Appelle le device au moins une fois! BUG!
  295. .PaSet    move.l    (a2),a1
  296.     Rbra    L_Stpar
  297.  
  298. ***********************************************************
  299. *    Serclose [N]
  300. L_SerClo1    equ    5
  301. L5    move.l    (a3)+,d0
  302.     Rbsr    L_GetSerial
  303.     Rjmp    L_Dev.Close
  304. ;-----> Close ALL channels
  305. L_SerClo0    equ    6    
  306. L_SCloseA    equ    6
  307. L6    Dlea    SerialIO,a2
  308.     moveq    #NSerial-1,d2
  309. SCloA1    Rjsr    L_Dev.Close
  310.     lea    12(a2),a2
  311.     dbra    d2,SCloA1
  312.     rts
  313. L7    
  314.  
  315. ***********************************************************
  316. *    Serial Send ser,A$
  317. L_SerSend    equ    8
  318. L8    move.l    (a3)+,d2
  319.     move.l    (a3)+,d0
  320.     Rbsr    L_GetSerA1
  321.     move.l    d2,a0
  322.     moveq    #0,d0
  323.     move.w    (a0)+,d0
  324.     Rbeq    L_IFonc
  325.     move.l    d0,IO_LENGTH(a1)
  326.     move.l    a0,IO_DATA(a1)
  327.     moveq    #CMD_WRITE,d0
  328.     Rjmp    L_Dev.SendIO
  329. ***********************************************************
  330. *    Serial Out ser,address,length
  331. L_SerOut    equ    9
  332. L9    move.l    (a3)+,d2
  333.     Rbmi    L_IFonc
  334.     Rbeq    L_IFonc
  335.     move.l    (a3)+,d1
  336.     move.l    (a3)+,d0
  337.     Rbsr    L_GetSerA1
  338.     move.l    d1,IO_DATA(a1)
  339.     move.l    d2,IO_LENGTH(a1)
  340.     moveq    #CMD_WRITE,d0
  341.     Rjmp    L_Dev.SendIO
  342. ***********************************************************
  343. *    =Serial Get(ser)
  344. L_SerGet    equ    10
  345. L10    move.l    (a3)+,d0
  346.     Rbsr    L_GetSerA1
  347.     move.w    #SDCMD_QUERY,d0
  348.     Rjsr    L_Dev.DoIO
  349.     moveq    #-1,d3
  350.     move.l    IO_ACTUAL(a1),d0
  351.     beq.s    SerINo
  352.     Dlea    BufIn,a0
  353.     move.l    a0,IO_DATA(a1)
  354.     move.l    #1,IO_LENGTH(a1)
  355.     moveq    #CMD_READ,d0
  356.     Rjsr    L_Dev.DoIO
  357.     moveq    #0,d3
  358.     Dlea    BufIn,a0
  359.     move.b    (a0),d3
  360. SerINo    moveq    #0,d2
  361.     rts
  362. ***********************************************************
  363. *    =Serial Input$(Ser) 
  364. L_SerInp    equ    11
  365. L11    move.l    (a3)+,d0
  366.     Rbsr    L_GetSerA1
  367.     moveq    #SDCMD_QUERY,d0
  368.     Rjsr    L_Dev.DoIO
  369.     move.l    IO_ACTUAL(a1),d4
  370.     beq.s    SInpNo
  371.     cmp.l    #65530,d4
  372.     Rbcc    L_IFonc
  373. * Ask for string space...
  374.     movem.l    a1/a2,-(sp)
  375.     move.l    d4,d3
  376.     and.w    #$FFFE,d3        * Only EVEN!
  377.     addq.w    #2,d3
  378.     Rjsr    L_Demande
  379.     lea    2(a1,d3.w),a1
  380.     move.l    a1,HiChaine(a5)
  381. * Send to device...
  382.     movem.l    (sp)+,a1/a2
  383.     move.l    a0,d3
  384.     move.w    d4,(a0)+
  385.     move.l    a0,IO_DATA(a1)
  386.     move.l    d4,IO_LENGTH(a1)
  387.     moveq    #CMD_READ,d0
  388.     Rjsr    L_Dev.DoIO
  389.     moveq    #2,d2
  390.     rts
  391. * Nothing to return
  392. SInpNo    move.l    ChVide(a5),d3        * Empty string
  393.     moveq    #2,d2
  394.     rts
  395.  
  396. ***********************************************************
  397. *    Serial Speed ser,baud
  398. L_SerSp        equ    12
  399. L12    move.l    (a3)+,d1
  400.     move.l    (a3)+,d0
  401.     Rbsr    L_GetSerA1
  402.     move.l    d1,IO_BAUD(a1)
  403.     Rbra    L_Stpar
  404. L_Stpar        equ    13
  405. L13    moveq    #SDCMD_SETPARAMS,d0
  406.     Rjmp    L_Dev.DoIO
  407. ***********************************************************
  408. *    Serial Bit ser,number,stop
  409. L_SerBit    equ    14
  410. L14    move.l    (a3)+,d2
  411.     move.l    (a3)+,d1
  412.     move.l    (a3)+,d0
  413.     Rbsr    L_GetSerA1
  414.     move.b    d1,IO_READLEN(a1)
  415.     move.b    d1,IO_WRITELEN(a1)
  416.     move.b    d2,IO_STOPBITS(a1)
  417.     Rbra    L_Stpar
  418. ***********************************************************
  419. *    Serial Parity ser,on/off/odd/even/mspon
  420. L_SerPar    equ    15
  421. L15    move.l    (a3)+,d1
  422.     move.l    (a3)+,d0
  423.     Rbsr    L_GetSerA1
  424.     bclr    #SERB_PARTY_ON,IO_SERFLAGS(a1)
  425.     bclr    #SERB_PARTY_ODD,IO_SERFLAGS(a1)
  426.     bclr    #SEXTB_MSPON,IO_EXTFLAGS+3(a1)
  427.     bclr    #SEXTB_MARK,IO_EXTFLAGS+3(a1)
  428. ; -1-> NO PARITY
  429.     tst.w    d1
  430.     bmi.s    .parX
  431. ; 0--> EVEN
  432.     bne.s    .par1
  433.     bset    #SERB_PARTY_ON,IO_SERFLAGS(a1)
  434.     bra.s    .parX
  435. ; 1--> ODD
  436. .par1    cmp.w    #1,d1
  437.     bne.s    .par2
  438.     bset    #SERB_PARTY_ON,IO_SERFLAGS(a1)
  439.     bset    #SERB_PARTY_ODD,IO_SERFLAGS(a1)
  440.     bra.s    .parX
  441. ; 2--> SPACE
  442. .par2    cmp.w    #2,d1
  443.     bne.s    .par3
  444.     bset    #SEXTB_MSPON,IO_EXTFLAGS+3(a1)
  445.     bra.s    .parX
  446. ; 3--> MARK
  447. .par3    cmp.w    #3,d1
  448.     bne.s    .parX
  449.     bset    #SEXTB_MSPON,IO_EXTFLAGS+3(a1)
  450.     bset    #SEXTB_MARK,IO_EXTFLAGS+3(a1)
  451. ; Envoie
  452. .parX    Rbra    L_Stpar    
  453. **********************************************************
  454. *    Serial X ser,value
  455. L_SerX        equ    16
  456. L16    move.l    (a3)+,d1
  457.     move.l    (a3)+,d0
  458.     Rbsr    L_GetSerA1
  459.     bset    #SERB_XDISABLED,IO_SERFLAGS(a1)
  460.     cmp.l    #-1,d1
  461.     Rbeq    L_Stpar
  462.     bclr    #SERB_XDISABLED,IO_SERFLAGS(a1)
  463.     move.l    d1,IO_CTLCHAR(a1)
  464.     Rbra    L_Stpar
  465. **********************************************************
  466. *    Serial Buffer ser,length
  467. L_SerBuf    equ    17
  468. L17    move.l    (a3)+,d1
  469.     move.l    (a3)+,d0
  470.     Rbsr    L_GetSerA1
  471.     move.l    d1,IO_RBUFLEN(a1)
  472.     Rbra    L_Stpar
  473. **********************************************************
  474. *    Serial Fast ser
  475. L_SerFast    equ    18
  476. L18    move.l    (a3)+,d0
  477.     Rbsr    L_GetSerA1
  478.     bclr    #SERB_PARTY_ON,IO_SERFLAGS(a1)
  479.     bclr    #SEXTB_MSPON,IO_EXTFLAGS+3(a1)
  480.     bset    #SERB_XDISABLED,IO_SERFLAGS(a1)
  481.     move.b    #8,IO_READLEN(a1)
  482.     move.b    #8,IO_WRITELEN(a1)
  483.     bset    #SERB_RAD_BOOGIE,IO_SERFLAGS(a1)
  484.     Rbra    L_Stpar
  485. **********************************************************
  486. *    Serial Slow Ser
  487. L_SerSlow    equ    19
  488. L19    move.l    (a3)+,d0
  489.     Rbsr    L_GetSerA1
  490.     bclr    #SERB_RAD_BOOGIE,IO_SERFLAGS(a1)
  491.     Rbra    L_Stpar
  492. **********************************************************
  493. *    =Serial Check(N)
  494. L_SerChk    equ    20
  495. L20    move.l    (a3)+,d0
  496.     Rbsr    L_GetSerial
  497.     Rjsr    L_Dev.CheckIO
  498.     move.l    d0,d3
  499.     beq.s    SerChk1
  500.     moveq    #-1,d3
  501. SerChk1    moveq    #0,d2    
  502.     rts
  503. **********************************************************
  504. *    =Serial Error(n)
  505. L_SerE        equ    21
  506. L21    move.l    (a3)+,d0
  507.     Rbsr    L_GetSerA1
  508.     moveq    #0,d3
  509.     move.b    IO_ERROR(a1),d3
  510.     moveq    #0,d2
  511.     rts
  512.  
  513. **********************************************************
  514. *    =Serial Status(n)
  515. L_SerStatus    equ    22
  516. L22    move.l    (a3)+,d0
  517.     Rbsr    L_GetSerA1
  518.     moveq    #SDCMD_QUERY,d0
  519.     Rjsr    L_Dev.DoIO
  520.     moveq    #0,d3
  521.     move.l    (a2),a1
  522.     move.w    IO_STATUS(a1),d3
  523.     moveq    #0,d2
  524.     rts
  525.  
  526. **********************************************************
  527. *        =SERIAL BASE
  528. L_SerBase    equ    23    
  529. L23    move.l    (a3)+,d0
  530.     Rbsr    L_GetSerA1
  531.     move.l    a1,d3
  532.     moveq    #0,d2    
  533.     rts
  534.  
  535. ;-----> IO #D0 to A1/a2
  536. L_GetSerA1    equ    24
  537. L24    Rbsr    L_GetSerial
  538.     Rjmp    L_Dev.GetIO
  539. ;-----> Find IO address > D0
  540. L_GetSerial    equ    25
  541. L25    cmp.l    #NSerial,d0
  542.     Rbcc    L_IFonc
  543.     mulu    #12,d0
  544.     Dlea    SerialIO,a2
  545.     add.w    d0,a2
  546.     rts
  547.  
  548. *********************************************************************
  549. *        SERIAL ABORT channel
  550. L_SerAbort    equ    26
  551. L26    move.l    (a3)+,d0
  552.     Rbsr    L_GetSerial
  553.     Rjmp    L_Dev.AbortIO
  554.  
  555. L27
  556. L28
  557. *********************************************************************
  558. *    ERRORS
  559. L_IFonc        equ    29
  560. L29    moveq    #23,d0            * Illegal function call
  561.     Rjmp    L_Error
  562. L30    
  563. L31
  564. L32
  565.  
  566. **********************************************************
  567. *        =PRINTER BASE
  568. L_PrtBase    equ    33
  569. L33    Dlea    PrinterIO,a2
  570.     Rjsr    L_Dev.GetIO
  571.     move.l    a1,d3
  572.     moveq    #0,d2    
  573.     rts
  574. **********************************************************
  575. *        =PRINTER CHECK
  576. L_PrtCheck    equ    34
  577. L34    Dlea    PrinterIO,a2
  578.     Rjsr    L_Dev.CheckIO
  579.     move.l    d0,d3
  580.     beq.s    PrtChk1
  581.     moveq    #-1,d3
  582. PrtChk1    moveq    #0,d2    
  583.     rts
  584.  
  585. *********************************************************************
  586. *        PRINTER OPEN
  587. L_PrtOpen    equ    35
  588. L35    Dlea    PrtName,a0
  589.     Dlea    PrinterIO,a2
  590.     moveq    #64,d0
  591.     moveq    #0,d1
  592.     moveq    #0,d2
  593.     move.w    #161,d3        Premier message erreurs
  594.     moveq    #7,d4        7 messages
  595.     moveq    #0,d5
  596.     Rjmp    L_Dev.Open
  597.  
  598. *********************************************************************
  599. *        PRINTER CLOSE
  600. L_PrtClose    equ    36
  601. L36    Dlea    PrinterIO,a2
  602.     Rjmp    L_Dev.Close
  603.  
  604. *********************************************************************
  605. *        =PRINTER ERROR
  606. L_PrtError    equ    37
  607. L37    Dlea    PrinterIO,a2
  608.     Rjsr    L_Dev.GetIO
  609.     moveq    #0,d3
  610.     move.b    IO_ERROR(a1),d3
  611.     moveq    #0,d2
  612.     rts
  613.  
  614. ***********************************************************
  615. *        PRINTER SEND A$
  616. L_PrtSend    equ    38
  617. L38    Dlea    PrinterIO,a2
  618.     Rjsr    L_Dev.GetIO
  619.     move.l    (a3)+,a0
  620.     moveq    #0,d0
  621.     move.w    (a0)+,d0
  622.     Rbeq    L_IFonc
  623.     move.l    d0,IO_LENGTH(a1)
  624.     move.l    a0,IO_DATA(a1)
  625.     moveq    #CMD_WRITE,d0
  626.     Rjmp    L_Dev.SendIO
  627.  
  628. ***********************************************************
  629. *        PRINTER SENDRAW ad,lenght
  630. L_PrtRaw    equ    39
  631. L39    Dlea    PrinterIO,a2
  632.     Rjsr    L_Dev.GetIO
  633.     move.l    (a3)+,d0
  634.     Rbeq    L_IFonc
  635.     move.l    (a3)+,a0
  636.     move.l    d0,IO_LENGTH(a1)
  637.     move.l    a0,IO_DATA(a1)
  638.     moveq    #PRD_RAWWRITE,d0
  639.     Rjmp    L_Dev.SendIO
  640.  
  641. *********************************************************************
  642. *        PRINTER ABORT
  643. L_PrtAbort    equ    40
  644. L40    Dlea    PrinterIO,a2
  645.     Rjmp    L_Dev.AbortIO
  646.  
  647. *********************************************************************
  648. *        =PRINTER ONLINE
  649. L_PrtOnLine    equ    41
  650. L41    Dlea    PrinterIO,a2
  651.     Rjsr    L_Dev.GetIO
  652.     Dlea    Prt_Query,a0
  653.     move.l    a0,IO_DATA(a1)
  654.     moveq    #PRD_QUERY,d0
  655.     Rjsr    L_Dev.DoIO
  656.     Dlea    Prt_Query,a0
  657.     moveq    #0,d3
  658.     move.l    (a2),a1
  659.     cmp.l    #1,IO_ACTUAL(a1)
  660.     bne.s    .Skip
  661.     btst    #0,(a0)
  662.     bne.s    .Skip
  663.     moveq    #-1,d3
  664. .Skip    moveq    #0,d2
  665.     rts
  666.  
  667. *********************************************************************
  668. *        PRINTER DUMP
  669.  
  670. ; No parameters
  671. ; ~~~~~~~~~~~~~
  672. L_PrtDump1    equ    42
  673. L42    Dload    a2
  674.     Rbsr    L_GetScr
  675.     move.w    width-DT(a2),pwidth-DT(a2)
  676.     move.w    height-DT(a2),pheight-DT(a2)
  677.     move.l    #0,destCols-DT(a2)
  678.     move.l    #0,destRows-DT(a2)
  679.     move.w    #$8c,special-DT(a2)    ; ASPECT | FULLROWS | FULLCOLS
  680.     Rbra    L_Dump
  681.  
  682. ; Four parameters
  683. ; ~~~~~~~~~~~~~~~
  684. L_PrtDump2    equ    43
  685. L43    Dload    a2
  686.     Rbsr    L_Dump2a
  687.     
  688. ; Calculate proportional DestX, DestY
  689.     clr.l    d0
  690.     clr.l    d1
  691.     move.w    pwidth-DT(a2),d0
  692.     tst.w    d0
  693.     Rbeq    L_IFonc    
  694.     move.w    width-DT(a2),d1
  695.     divu.w    d0,d1
  696.     tst.w    d1
  697.     Rbeq    L_IFonc
  698.     lea    destCols-DT(a2),a0
  699.     move.l    #$ffff,d0
  700.     divu.w    d1,d0
  701.     move.l    d0,(a0)
  702.     andi.l    #$ffff,(a0)
  703.     move.l    #$10,d1
  704.     move.l    (a0),d0
  705.     rol.l    d1,d0
  706.     move.l    d0,(a0)
  707.  
  708.     clr.l    d0
  709.     clr.l    d1
  710.     move.w    pheight-DT(a2),d0
  711.     tst.w    d0
  712.     Rbeq    L_IFonc
  713.     move.w    height-DT(a2),d1
  714.     divu.w    d0,d1
  715.     tst.w    d1
  716.     Rbeq    L_IFonc
  717.     lea    destRows-DT(a2),a0
  718.     move.l    #$ffff,d0
  719.     divu.w    d1,d0
  720.     move.l    d0,(a0)
  721.     andi.l    #$ffff,(a0)
  722.     move.l    #$10,d1
  723.     move.l    (a0),d0
  724.     rol.l    d1,d0
  725.     move.l    d0,(a0)
  726.     lea    special-DT(a2),a0
  727.     move.w    #$b0,(a0)
  728.     Rbra     L_Dump
  729.  
  730. ; Tous les parametres
  731. ; ~~~~~~~~~~~~~~~~~~~
  732. L_PrtDump3    equ    44
  733. L44    movem.l    a4-a6,-(sp)
  734.     Dload    a2
  735.     Rbsr    L_Dump3a
  736.     Rbra    L_Dump
  737.  
  738. ; DUMP Routines...
  739. ; ~~~~~~~~~~~~~~~~
  740. L_Dump3a    equ    45
  741. L45    lea    special-DT(a2),a0
  742.     lea    2(a3),a3
  743.     move.w    (a3)+,(a0)        ; special
  744.     lea    destRows-DT(a2),a0
  745.     move.l    (a3)+,(a0)        ; destY
  746.     lea    destCols-DT(a2),a0
  747.     move.l    (a3)+,(a0)        ; destY
  748.     Rbra    L_Dump2a
  749. L_Dump2a    equ    46
  750. L46    lea    pheight-DT(a2),a0
  751.     lea    2(a3),a3
  752.     move.w    (a3)+,(a0)        ; bottom y
  753.     lea    pwidth-DT(a2),a0
  754.     lea    2(a3),a3
  755.     move.w    (a3)+,(a0)        ; bottom x
  756.     lea    srcY-DT(a2),a0
  757.     lea    2(a3),a3
  758.     move.w    (a3)+,(a0)        ; srcy
  759.     lea    srcX-DT(a2),a0
  760.     lea    2(a3),a3
  761.     move.w    (a3)+,(a0)        ; srcx
  762.     Rbsr    L_GetScr
  763. ; get srcX,Y back
  764.     move.w    srcX-DT(a2),d0
  765.     move.w    srcY-DT(a2),d1
  766. ; calculate width, height
  767.     neg.w    d0
  768.     neg.w    d1
  769.     lea    pwidth-DT(a2),a0
  770.     add.w    d0,(a0)            ; width = -srcX+bottomX
  771.     lea    pheight-DT(a2),a0
  772.     add.w    d1,(a0)            ; height = -srcY+bottomY
  773.     rts
  774. ; Do the screen dump
  775. ; ~~~~~~~~~~~~~~~~~~
  776. L_Dump        equ    47
  777. L47    
  778. ; Initialise colour map
  779.     moveq    #32,d0
  780.     move.l    a6,-(sp)
  781.     move.l    T_GfxBase(a5),a6
  782.     jsr    -570(a6)
  783.     move.l    (sp)+,a6
  784.     tst.l    d0
  785.     beq    cl5
  786.     move.l    d0,colourmap-DT(a2)
  787.     move.l    d0,a0
  788.     moveq    #0,d0
  789.     move.l    ScreenBase-DT(a2),a1
  790.     lea    EcPal(a1),a1
  791. .loop    move.w    (a1)+,d1
  792.     move.w    d1,d3
  793.     and.w    #$f,d3
  794.     lsr.w    #4,d1
  795.     move.w    d1,d2
  796.     and.w    #$f,d2
  797.     lsr.w    #4,d1
  798.     movem.l    d0/a0-a1/a6,-(sp)
  799.     move.l    T_GfxBase(a5),a6
  800.     jsr    -$276(a6)
  801.     movem.l    (sp)+,d0/a0-a1/a6
  802.     addq.w    #1,d0
  803.     cmp.w    #32,d0
  804.     bne.s    .loop
  805.  
  806. ; Dump the rast port!!!
  807.     move.l    PrinterIO-DT(a2),a1
  808.     move.w    #11,28(a1)        ; command
  809.     move.l    T_RastPort(a5),32(a1)    ; rastPort
  810.     move.l    colourmap-DT(a2),36(a1)    ; colourmap
  811.     move.w    viewModes-DT(a2),40+2(a1)    ; viewmodes
  812.     move.w    srcX-DT(a2),44(a1)    ; srcX
  813.     move.w    srcY-DT(a2),46(a1)    ; srcY
  814.     move.w    pwidth-DT(a2),48(a1)    ; srcWidth
  815.     move.w    pheight-DT(a2),50(a1)    ; srcHeight
  816.     move.l    destCols-DT(a2),52(a1)    ; destCols
  817.     move.l    destRows-DT(a2),56(a1)    ; destRows
  818.     move.w    special-DT(a2),60(a1)    ; special
  819.     move.l    a6,-(sp)
  820.     move.l    $4.w,a6
  821.     jsr    _LVOSendIO(a6)        ; Do it!!!! (at last)
  822.     move.l    (sp)+,a6
  823.     move.w    d0,-(sp)
  824.  
  825. ; Free colour map
  826. cl8    move.l    colourmap-DT(a2),a0
  827.     move.l    a6,-(sp)
  828.     move.l    T_GfxBase(a5),a6
  829.     jsr    -576(a6)        ; Free colourmap
  830.     move.l    (sp)+,a6
  831. cl5
  832. ; Return to the user
  833.     move.w    (sp)+,d0
  834.     bne.s    .Err
  835.     rts
  836. ; Error
  837. .Err    Rjmp    L_Dev.Error
  838.  
  839. ; Return informations about the current screen
  840. ; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  841. L_GetScr    equ    48
  842. L48    move.l    ScOnAd(a5),d0    
  843.     beq.s    .Err                ; get the address of the screen 
  844.     move.l    d0,a0
  845.     move.l     a0,ScreenBase-DT(a2)
  846. ; Now we need to extract all the information about the screen
  847.     move.w    EcTx(a0),width-DT(a2)        ; width
  848.     move.w    EcTy(a0),height-DT(a2)        ; height
  849.     move.w    EcCon0(a0),d0
  850.     and.w    #%1000100010000100,d0        ; Hires / HAM / DualPF / Halfbrite
  851.     move.w    d0,viewModes-DT(a2)        ; View Modes
  852.     move.w    EcNPlan(a0),depth-DT(a2)    ; depth
  853.     rts
  854. .Err    moveq    #47,d0                ; Screen not opened
  855.     Rjmp    L_Error
  856.  
  857. L49
  858. L50
  859. L51
  860. L52
  861. **********************************************************
  862. *        =PARALLEL BASE
  863. L_ParBase    equ    53
  864. L53    Dlea    ParallelIO,a2
  865.     Rjsr    L_Dev.GetIO
  866.     move.l    a1,d3
  867.     moveq    #0,d2    
  868.     rts
  869.  
  870. **********************************************************
  871. *        =PARALLEL CHECK
  872. L_ParCheck    equ    54
  873. L54    Dlea    ParallelIO,a2
  874.     Rjsr    L_Dev.CheckIO
  875.     move.l    d0,d3
  876.     beq.s    ParChk1
  877.     moveq    #-1,d3
  878. ParChk1    moveq    #0,d2    
  879.     rts
  880.  
  881. *********************************************************************
  882. *        PARALLEL OPEN
  883. L_ParOpen    equ    55
  884. L55    Dlea    ParName,a0
  885.     Dlea    ParallelIO,a2
  886.     moveq    #62,d0
  887.     moveq    #0,d1
  888.     moveq    #0,d2
  889.     move.w    #171,d3        Premier message erreurs
  890.     moveq    #7,d4        7 messages
  891.     moveq    #0,d5
  892.     Rjmp    L_Dev.Open
  893.  
  894. *********************************************************************
  895. *        PARALLEL CLOSE
  896. L_ParClose    equ    56
  897. L56    Dlea    ParallelIO,a2
  898.     Rjmp    L_Dev.Close
  899.  
  900. *********************************************************************
  901. L57
  902.  
  903. ***********************************************************
  904. *        PARALLEL SEND A$
  905. L_ParSend    equ    58
  906. L58    Dlea    ParallelIO,a2
  907.     Rjsr    L_Dev.GetIO
  908.     move.l    (a3)+,a0
  909.     moveq    #0,d0
  910.     move.w    (a0)+,d0
  911.     Rbeq    L_IFonc
  912.     move.l    d0,IO_LENGTH(a1)
  913.     move.l    a0,IO_DATA(a1)
  914.     moveq    #CMD_WRITE,d0
  915.     Rjmp    L_Dev.DoIO
  916.  
  917. ***********************************************************
  918. *        PARALLEL SENDRAW ad,lenght
  919. L_ParRaw    equ    59
  920. L59    Dlea    ParallelIO,a2
  921.     Rjsr    L_Dev.GetIO
  922.     move.l    (a3)+,d0
  923.     Rbeq    L_IFonc
  924.     move.l    (a3)+,a0
  925.     move.l    d0,IO_LENGTH(a1)
  926.     move.l    a0,IO_DATA(a1)
  927.     moveq    #PRD_RAWWRITE,d0
  928.     Rjmp    L_Dev.DoIO
  929.  
  930. *********************************************************************
  931. *        PARALLEL ABORT
  932. L_ParAbort    equ    60
  933. L60    Dlea    ParallelIO,a2
  934.     Rjmp    L_Dev.AbortIO
  935.  
  936. *********************************************************************
  937. *        =PARALLEL STATUS
  938. L_ParStatus    equ    61
  939. L61    Dlea    ParallelIO,a2
  940.     Rjsr    L_Dev.GetIO
  941.     moveq    #PDCMD_QUERY,d0
  942.     Rjsr    L_Dev.DoIO
  943.     moveq    #0,d3
  944.     move.l    (a2),a1
  945.     move.b    $34(a1),d3
  946.     moveq    #0,d2
  947.     rts
  948.  
  949. *********************************************************************
  950. *        =PARALLEL ERROR
  951. L_ParError    equ    62
  952. L62    Dlea    ParallelIO,a2
  953.     Rjsr    L_Dev.GetIO
  954.     moveq    #0,d3
  955.     move.l    (a2),a1
  956.     move.b    IO_ERROR(a1),d3
  957.     moveq    #0,d2
  958.     rts
  959.  
  960. *********************************************************************
  961. *        =PARALLEL INPUT$(long[,stop])
  962. L_ParInput1    equ    63
  963. L63    Dlea    ParallelIO,a2
  964.     Rjsr    L_Dev.GetIO
  965.     bclr    #PARB_EOFMODE,IO_PARFLAGS(a1)
  966.     Rbra    L_ParInput
  967. L_ParInput2    equ    64
  968. L64    Dlea    ParallelIO,a2
  969.     Rjsr    L_Dev.GetIO
  970.     move.l    (a3)+,d3
  971.     bset    #PARB_EOFMODE,IO_PARFLAGS(a1)
  972.     beq.s    .Set
  973.     cmp.b    IO_PTERMARRAY(a1),d3
  974.     beq.s    .Skip
  975. .Set    moveq    #7,d0
  976.     lea    IO_PTERMARRAY(a1),a0
  977. .Loop    move.b    d3,(a0)+
  978.     dbra    d0,.Loop
  979.     moveq    #PDCMD_SETPARAMS,d0
  980.     Rjsr    L_Dev.DoIO
  981. .Skip    Rbra    L_ParInput
  982. ; Appel
  983. L_ParInput    equ    65
  984. L65    move.l    (a3)+,d4
  985.     Rble    L_IFonc
  986.     cmp.l    #65000,d4
  987.     Rbcc    L_IFonc
  988. * Ask for string space...
  989.     movem.l    a1/a2,-(sp)
  990.     move.l    d4,d3
  991.     and.l    #$FFFE,d3
  992.     addq.w    #2,d3
  993.     Rjsr    L_Demande
  994.     lea    2(a1,d3.w),a1
  995.     move.l    a1,HiChaine(a5)
  996.     movem.l    (sp)+,a1/a2
  997. * Send to device...
  998.     move.l    a0,d3
  999.     move.w    d4,(a0)+
  1000.     move.l    a0,IO_DATA(a1)
  1001.     move.l    d4,IO_LENGTH(a1)
  1002.     moveq    #CMD_READ,d0
  1003.     Rjsr    L_Dev.DoIO
  1004.     moveq    #2,d2
  1005.     rts
  1006.  
  1007. L66
  1008. L67
  1009. L68
  1010. L69
  1011.  
  1012. **********************************************************************
  1013. *    SPACE FOR ERROR ROUTINES...
  1014. L70
  1015. L71
  1016. L72
  1017. *********************************************************************
  1018.  
  1019. ******* TITLE MESSAGE
  1020. C_Title    dc.b    "AMOSPro IO Devices Extension V "
  1021.     Version
  1022.     dc.b    0,"$VER: "
  1023.     Version
  1024.     dc.b    0
  1025.     Even
  1026.  
  1027. ******* END OF THE EXTENSION
  1028. C_End    dc.w    0
  1029.     even
  1030.